{% extends 'base.html' %}
{% block title %}
    登录
{% endblock %}
{% block content %}
<div class="layui-container fly-marginTop login_register">
  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief login_shadow" lay-filter="user">
      <ul class="layui-tab-title tilte_width">
        <li class="layui-this">登录</li>
        <li><a href="/User/register">注册</a></li>
      </ul>
      <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show">
          <div class="layui-form layui-form-pane">
            <form method="post">
              <div class="layui-form-item">
                <label for="username" class="layui-form-label label_width"><i class="layui-icon layui-icon-username"></i></label>
                <div class="layui-input-inline">
                  <input type="text" id="username" lay-verify="required|userName" name="username" value="{{ username }}" class="layui-input" placeholder="用户名">
                </div>
                  <div class="layui-form-mid layui-word-aux">{{ username_error }}</div>
              </div>
              <div class="layui-form-item">
                <label for="password" class="layui-form-label label_width"><i class="layui-icon layui-icon-password"></i></label>
                <div class="layui-input-inline">
                  <input type="password" id="password" lay-verify="required|pass" name="password" value="{{ password }}" class="layui-input" placeholder="密&nbsp;码">
                </div>
                <div class="layui-form-mid layui-word-aux">{{ password_error }}</div>
              </div>
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label label_width" ><i class="layui-icon layui-icon-vercode"></i></label>
                <div class="layui-input-inline">
                  <input type="text" id="code" name="code" lay-verify="required|vercodes" value="" class="layui-input" placeholder="验证码">
                </div>
                  <div class="layui-form-mid layui-word-aux"></div>
                  <div class="zylVerCode vercode" onclick="zylVerCode()"></div>

              </div>
              <div class="layui-form-item login_button">
                <button class="layui-btn" lay-filter="*" lay-submit>立即登录</button>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>

</div>

<script>
			layui.use(['form'], function(){
				var form = layui.form;

				//自定义验证规则
				form.verify({
					userName: function(value){
						if(value.length < 5){
							return '账号至少得5个字符';
						}
					}
					,pass: [/^[\S]{6,12}$/,'密码必须6到12位，且不能出现空格']
					,vercodes: function(value){
						//获取验证码
						var zylVerCode = $(".zylVerCode").html();
						if(value!=zylVerCode){
							return '验证码错误（区分大小写）';
						}
					}
					,content: function(value){
						layedit.sync(editIndex);
					}
				});
		});
</script>

{% endblock %}